package com.tyk.bookstore.front.auth.model.enume;

import com.fasterxml.jackson.annotation.JsonValue;
import com.tyk.bookstore.front.auth.strategy.enume.LoginType;
import com.tyk.bookstore.front.common.core.model.enume.BaseEnum;

/**
 * @author tyk
 * @description LoginCodeType
 */
public enum LoginCodeType implements BaseEnum {
    PHONE(1),
    EMAIL(2);

    @JsonValue
    private final Integer code;

    LoginCodeType(Integer code) {
        this.code = code;
    }

    @Override
    public Integer value() {
        return this.code;
    }

    public LoginType toLoginType() {
        return switch (this) {
            case PHONE -> LoginType.PHONE_CODE;
            case EMAIL -> LoginType.EMAIL_CODE;
        };
    }
}
